﻿@model TechnicBlog.Models.StudentEntity
@{
    Layout = null;
}
<script type="text/javascript">
    $(function () {
        $("#rptList").datagrid({
            url: "Score/List/" + $("#S_Id").val() + "?r=" + Math.random(),
            onRowContextMenu: function (e, rowindex, rowData) {
                $("#rptList").datagrid('selectRow', rowindex);
                e.preventDefault();
                var row = $("#rptList").datagrid('getSelected');
                if (row) {
                    $('#menuScore').menu('show', {
                        left: e.pageX,
                        top: e.pageY
                    });
                }
            }

        });
    });
    function Add() {
        TreeLink('Score/Create/' + $("#S_Id").val(), '新增学生成绩')
    }
    function Edit() {
        var row = $("#rptList").datagrid('getSelected');
        if (row) {
            TreeLink('Score/Edit/' + row.Id, '学生成绩编辑');
        } else {
            $.messager.alert('错误', '<br>请先选择要编辑的数据！', 'error');
        }
    }
    function RequestError() {
        $.messager.alert('错误', '<br>请求失败！', 'error');
    }
    function Search() {
        $("#rptList").datagrid({
            url: "Score/List/" + $("#S_Id").val() + "?Term_Num=" + escape($.trim($("#Term_Num").val())) + "&r=" + Math.random(),
            pageNumber: 1
        }).datagrid('reload');
    }
    function formatTotal(val, row) {
        //val = "aa";
        //return val+"asdf";
        return "<div style='width:60px;'>" +(row.Chinese_Score + row.Math_Score + row.English_Score + row.Physics_Score + row.Chemistry_Score + row.Biology_Score)+"</div>";
    }
    function Delete() { 
        var row = $("#rptList").datagrid('getSelected');
        if (row) {
            $.messager.confirm('提醒', '<br>确定要删除' + row.Term_Num + '这一期的考试数据吗?', function (r) {
                if (r) {
                    form1.action = "Score/Delete/" + row.Id;
                    $('#loading').window('open');
                    $("#form1").ajaxSubmit({ action: this.action, method: this.method });
                }
            });
        } else {
            $.messager.alert('错误', '<br>请先选择要删除的数据！', 'error');
        }
    }
</script>
<form id="form1" action="Score/Delete" method="post" data-ajax-failure="RequestError"
data-ajax="true">
@Html.HiddenFor(model => model.S_Id)
@Html.HiddenFor(model => model.S_ClassesId, new { id="ClassesId"})
<div style="padding: 10px;">
    <table id="rptList" class="easyui-datagrid" width="100%" cache="false" title="Load Data"
        singleselect="true" toolbar="#tb" iconcls="icon-save" rownumbers="true" pagination="true"
        pagelist="[10,20,25,30]">
        <thead>
            <tr>
                
                <th field="Term_Num" width="100" align="center">
                    期次
                </th>
                <th field="Chinese_Score" width="60" align="center">
                    语文
                </th>
                <th field="Math_Score" width="60" align="center">
                    数学
                </th>
                <th field="English_Score" width="60" align="center">
                    英语
                </th>
                <th field="Physics_Score" width="60" align="center">
                    物理
                </th>
                <th field="Chemistry_Score" width="60" align="center">
                    化学
                </th>
                <th field="Biology_Score" width="60" align="center">
                    生物
                </th>
                <th align="center" formatter="formatTotal">
                   <div style="width:62px;"> 总分</div>
                </th>
                <th field="Id" hidden="true">
                    Id
                </th>
                <th field="S_Id" hidden="true">
                    S_Id
                </th>
            </tr>
        </thead>
    </table>
</div>
<div id="tb" style="height: auto">
    <div style="padding: 5px; height: 26px;">
        <a href="javascript:Add();" class="easyui-linkbutton" style="float: left;" iconcls="icon-add"
            plain="true">新增</a>
        <div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0)" onclick="Edit();" class="easyui-linkbutton" style="float: left;"
            iconcls="icon-edit" plain="true">编辑</a>
        <div class="dialog-tool-separator">
        </div>
<a href="javascript:void(0)" onclick="Delete();" class="easyui-linkbutton" style="float: left;"
            iconcls="icon-remove" plain="true">删除</a>
        <div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0);" class="easyui-linkbutton" style="float: left;" iconcls="icon-search"
            plain="true" onclick="javascript:Search();">查找</a>
        <div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0);" class="easyui-linkbutton" style="float: left;" iconcls="icon-back"
            plain="true" onclick="javascript:TreeLink('Student/Index/'+$('#ClassesId').val(), '学生基本信息列表');">返回</a>
    </div>
    <div style="border-top: 1px solid #CCCCCC; padding: 5px;">
        当前学生：<span style="color: #ff0000;">@Html.DisplayFor(model => model.S_Name)</span>&nbsp;&nbsp;&nbsp;&nbsp;
        班级：<span style="color: #ff0000;">@Html.DisplayFor(model => model.Classes.ClassName)
            </span>&nbsp;&nbsp;&nbsp;&nbsp; 考试期次:
        <input id="Term_Num" />
        <a href="javascript:Search();" class="easyui-linkbutton" iconcls="icon-search">Search</a>
    </div>
</div>
<div id="menuScore" class="easyui-menu" style="width: 120px;">
    <div iconcls="icon-edit" onclick="javascript:Edit();">
        编辑</div>
        <div class="menu-sep">
    </div>
    <div iconcls="icon-remove" onclick="javascript:Delete()">
        删除</div>
</div>
</form>
